package com.vrp3d.web;

import com.vrp3d.common.consts.CommonConst;
import com.vrp3d.common.enums.CommonExceptionEnum;
import com.vrp3d.common.response.RestResponse;
import com.vrp3d.domain.dto.booth.*;
import com.vrp3d.service.BoothService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author vrp3d
 */
@Api("展位")
@Slf4j
@Validated
@RestController
@RequestMapping("/booth")
public class BoothController extends AbsController {

    @Autowired
    private BoothService boothService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "预览模型")
    @ApiImplicitParam(name = "fileName", value = "模型文件路径", required = true, paramType = "query")
//    @RequestMapping(value = "/previewTheModel", method = RequestMethod.GET)
    public RestResponse previewTheModel(String fileName) {
        String filePath = boothService.previewTheModel(fileName);
        return new RestResponse().put(filePath);
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "回显展位上是否有信息(返回结果:展位上有信息存在的展位位置集合)")
    @ApiImplicitParam(name = "showroomId", value = "展厅id", required = true, paramType = "query", dataType = "int")
    @ApiResponses({
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/echoWhetherThereIsInformationOnTheBooth", method = RequestMethod.GET)
    public RestResponse echoWhetherThereIsInformationOnTheBooth(@NotNull(message = "展厅id不能为空") @Range(min = 1, message = "展厅id值最小为1") Integer showroomId) {
        List<Integer> result = boothService.echoWhetherThereIsInformationOnTheBooth(showroomId);
        return new RestResponse().put(result);
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "展位_自定义瓷器id")
    @ApiResponses({
          @ApiResponse(code = 200, message = "自定义瓷器id修改成功"),
    })
    @RequestMapping(value = "/modifyPorcelainId", method = RequestMethod.POST)
    public RestResponse modifyPorcelainId(@Validated @RequestBody BoothPorcelainIdDTO dto) {
        boothService.modifyPorcelainId(dto);
        return new RestResponse(CommonExceptionEnum.PORCELAIN_ID_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "展位_作品名称")
    @ApiResponses({
          @ApiResponse(code = 200, message = "作品名称修改成功"),
          @ApiResponse(code = 20005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/modifyWorkName", method = RequestMethod.POST)
    public RestResponse modifyWorkName(@Validated @RequestBody BoothWorkNameDTO dto) {
        boothService.modifyWorkName(dto);
        return new RestResponse(CommonExceptionEnum.THE_WORK_NAME_WAS_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "展位_展品类别")
    @ApiResponses({
          @ApiResponse(code = 200, message = "展品类别修改成功"),
          @ApiResponse(code = 21018, message = "展品类别不能为空"),
    })
    @RequestMapping(value = "/modifyExhibitsRange", method = RequestMethod.POST)
    public RestResponse modifyExhibitsRange(@Validated @RequestBody BoothExhibitsRangeDTO dto) {
        boothService.modifyExhibitsRange(dto);
        return new RestResponse(CommonExceptionEnum.EXHIBIT_CATEGORY_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "展位_制作标准")
    @ApiResponses({
          @ApiResponse(code = 200, message = "制作标准修改成功"),
          @ApiResponse(code = 20020, message = "制作标准不能为空"),
    })
    @RequestMapping(value = "/modifyProductionStandard", method = RequestMethod.POST)
    public RestResponse modifyProductionStandard(@Validated @RequestBody BoothProductionStandardDTO dto) {
        boothService.modifyProductionStandard(dto);
        return new RestResponse(CommonExceptionEnum.THE_PRODUCTION_STANDARD_HAS_BEEN_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "展位_作者名称")
    @ApiResponses({
          @ApiResponse(code = 200, message = "作者名称修改成功"),
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/modifyAuthorName", method = RequestMethod.POST)
    public RestResponse modifyAuthorName(@Validated @RequestBody BoothAuthorNameDTO dto) {
        boothService.modifyAuthorName(dto);
        return new RestResponse(CommonExceptionEnum.AUTHOR_NAME_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "展位_器型")
    @ApiResponses({
          @ApiResponse(code = 200, message = "器型修改成功"),
          @ApiResponse(code = 20022, message = "器型不能为空"),
    })
    @RequestMapping(value = "/modifyShape", method = RequestMethod.POST)
    public RestResponse modifyShape(@Validated @RequestBody BoothShapeDTO dto) {
        boothService.modifyShape(dto);
        return new RestResponse(CommonExceptionEnum.MODEL_MODIFICATION_SUCCEEDED.getMsg());
    }

    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "展位_图案")
    @ApiResponses({
          @ApiResponse(code = 200, message = "图案修改成功"),
          @ApiResponse(code = 20024, message = "图案不能为空"),
    })
    @RequestMapping(value = "/modifyPattern", method = RequestMethod.POST)
    public RestResponse modifyPattern(@Validated @RequestBody BoothPatternDTO dto) {
        boothService.modifyPattern(dto);
        return new RestResponse(CommonExceptionEnum.PATTERN_MODIFICATION_SUCCEEDED.getMsg());
    }

    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "展位_工艺")
    @ApiResponses({
          @ApiResponse(code = 200, message = "工艺修改成功"),
          @ApiResponse(code = 20026, message = "工艺不能为空"),
    })
    @RequestMapping(value = "/modifyTechnology", method = RequestMethod.POST)
    public RestResponse modifyTechnology(@Validated @RequestBody BoothTechnologyDTO dto) {
        boothService.modifyTechnology(dto);
        return new RestResponse(CommonExceptionEnum.PROCESS_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 10)
    @ApiOperation(value = "展位_分类")
    @ApiResponses({
          @ApiResponse(code = 200, message = "分类修改成功"),
          @ApiResponse(code = 20028, message = "分类不能为空"),
    })
    @RequestMapping(value = "/modifyType", method = RequestMethod.POST)
    public RestResponse modifyType(@Validated @RequestBody BoothTypeDTO dto) {
        boothService.modifyType(dto);
        return new RestResponse(CommonExceptionEnum.CATEGORY_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 11)
    @ApiOperation(value = "展位_用料")
    @ApiResponses({
          @ApiResponse(code = 200, message = "用料修改成功"),
          @ApiResponse(code = 20030, message = "用料不能为空"),
    })
    @RequestMapping(value = "/modifyMaterial", method = RequestMethod.POST)
    public RestResponse modifyMaterial(@Validated @RequestBody BoothMaterialDTO dto) {
        boothService.modifyMaterial(dto);
        return new RestResponse(CommonExceptionEnum.THE_MATERIAL_IS_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 12)
    @ApiOperation(value = "展位_高度")
    @ApiResponses({
          @ApiResponse(code = 200, message = "高度修改成功"),
    })
    @RequestMapping(value = "/modifyHighly", method = RequestMethod.POST)
    public RestResponse modifyHighly(@Validated @RequestBody BoothHighlyDTO dto) {
        boothService.modifyHighly(dto);
        return new RestResponse(CommonExceptionEnum.HIGHLY_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 13)
    @ApiOperation(value = "展位_口径")
    @ApiResponses({
          @ApiResponse(code = 200, message = "口径修改成功"),
    })
    @RequestMapping(value = "/modifyCal", method = RequestMethod.POST)
    public RestResponse modifyCal(@Validated @RequestBody BoothCalDTO dto) {
        boothService.modifyCal(dto);
        return new RestResponse(CommonExceptionEnum.CAL_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 14)
    @ApiOperation(value = "展位_肚径")
    @ApiResponses({
          @ApiResponse(code = 200, message = "口径修改成功"),
    })
    @RequestMapping(value = "/modifyBellySize", method = RequestMethod.POST)
    public RestResponse modifyBellySize(@Validated @RequestBody BoothBellySizeDTO dto) {
        boothService.modifyBellySize(dto);
        return new RestResponse(CommonExceptionEnum.BELLY_DIAMETER_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 15)
    @ApiOperation(value = "展位_底径")
    @ApiResponses({
          @ApiResponse(code = 200, message = "底径修改成功"),
    })
    @RequestMapping(value = "/modifyBottomDiameter", method = RequestMethod.POST)
    public RestResponse modifyBottomDiameter(@Validated @RequestBody BoothBottomDiameterDTO dto) {
        boothService.modifyBottomDiameter(dto);
        return new RestResponse(CommonExceptionEnum.LOW_PATH_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 16)
    @ApiOperation(value = "展位_配置")
    @ApiResponses({
          @ApiResponse(code = 200, message = "配置修改成功"),
          @ApiResponse(code = 20036, message = "配置不能为空"),
    })
    @RequestMapping(value = "/modifyConfiguration", method = RequestMethod.POST)
    public RestResponse modifyConfiguration(@Validated @RequestBody BoothConfigurationDTO dto) {
        boothService.modifyConfiguration(dto);
        return new RestResponse(CommonExceptionEnum.CONFIGURATION_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 17)
    @ApiOperation(value = "展位_工艺特色")
    @ApiResponses({
          @ApiResponse(code = 200, message = "工艺特色修改成功"),
          @ApiResponse(code = 20038, message = "工艺特色不能为空"),
    })
    @RequestMapping(value = "/modifyProcessCharacteristic", method = RequestMethod.POST)
    public RestResponse modifyProcessCharacteristic(@Validated @RequestBody BoothProcessCharacteristicDTO dto) {
        boothService.modifyProcessCharacteristic(dto);
        return new RestResponse(CommonExceptionEnum.PROCESS_CHARACTERISTICS_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 18)
    @ApiOperation(value = "展位_艺术特色")
    @ApiResponses({
          @ApiResponse(code = 200, message = "艺术特色修改成功"),
          @ApiResponse(code = 20040, message = "艺术特色不能为空"),
    })
    @RequestMapping(value = "/modifyArtisticFeatures", method = RequestMethod.POST)
    public RestResponse modifyArtisticFeatures(@Validated @RequestBody BoothArtisticFeaturesDTO dto) {
        boothService.modifyArtisticFeatures(dto);
        return new RestResponse(CommonExceptionEnum.ARTISTIC_FEATURES_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 19)
    @ApiOperation(value = "展位_送展人")
    @ApiResponses({
          @ApiResponse(code = 200, message = "送展人修改成功"),
          @ApiResponse(code = 20042, message = "送展人不能为空"),
    })
    @RequestMapping(value = "/modifyTransportation", method = RequestMethod.POST)
    public RestResponse modifyTransportation(@Validated @RequestBody BoothTransportationDTO dto) {
        boothService.modifyTransportation(dto);
        return new RestResponse(CommonExceptionEnum.THE_EXHIBITOR_SUCCESSFULLY_MODIFIED.getMsg());
    }

    @ApiOperationSupport(order = 20)
    @ApiOperation(value = "展位_送展人电话")
    @ApiResponses({
          @ApiResponse(code = 200, message = "送展人电话修改成功"),
          @ApiResponse(code = 20044, message = "送展人电话不能为空"),
    })
    @RequestMapping(value = "/modifyPhone", method = RequestMethod.POST)
    public RestResponse modifyPhone(@Validated @RequestBody BoothPhoneDTO dto) {
        boothService.modifyPhone(dto);
        return new RestResponse(CommonExceptionEnum.THE_EXHIBITOR_PHONE_SUCCESSFULLY_MODIFIED.getMsg());
    }

    @ApiOperationSupport(order = 21)
    @ApiOperation(value = "展位_对接人员")
    @ApiResponses({
          @ApiResponse(code = 200, message = "对接人员修改成功"),
          @ApiResponse(code = 20046, message = "对接人员不能为空"),
    })
    @RequestMapping(value = "/modifyDockingPersonal", method = RequestMethod.POST)
    public RestResponse modifyDockingPersonal(@Validated @RequestBody BoothDockingPersonalDTO dto) {
        boothService.modifyDockingPersonal(dto);
        return new RestResponse(CommonExceptionEnum.THE_DOCKING_PERSON_HAS_BEEN_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 22)
    @ApiOperation(value = "展位_售价")
    @ApiResponses({
          @ApiResponse(code = 200, message = "售价修改成功"),
    })
    @RequestMapping(value = "/modifyPrice", method = RequestMethod.POST)
    public RestResponse modifyPrice(@Validated @RequestBody BoothPriceDTO dto) {
        boothService.modifyPrice(dto);
        return new RestResponse(CommonExceptionEnum.PRICE_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 23)
    @ApiOperation(value = "展位_备注")
    @ApiResponses({
          @ApiResponse(code = 200, message = "备注修改成功"),
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/modifyRemarks", method = RequestMethod.POST)
    public RestResponse modifyRemarks(@Validated @RequestBody BoothRemarksDTO dto) {
        boothService.modifyRemarks(dto);
        return new RestResponse(CommonExceptionEnum.REMARK_MODIFIED_SUCCESSFULLY.getMsg());
    }


    @ApiOperationSupport(order = 24)
    @ApiOperation(value = "展位_描述")
    @ApiResponses({
          @ApiResponse(code = 200, message = "描述修改成功"),
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/modifyIntroduction", method = RequestMethod.POST)
    public RestResponse modifyIntroduction(@Validated @RequestBody BoothIntroductionDTO dto) {
        boothService.modifyIntroduction(dto);
        return new RestResponse(CommonExceptionEnum.INTRODUCTION_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 25)
    @ApiOperation(value = "展位_音频")
    @ApiResponses({
          @ApiResponse(code = 200, message = "介绍修改成功"),
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/modifyAudio", method = RequestMethod.POST)
    public RestResponse modifyAudio(@Validated @RequestBody BoothAudioDTO dto) {
        boothService.modifyAudio(dto);
        return new RestResponse(CommonExceptionEnum.AUDIO_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 26)
    @ApiOperation(value = "展位_模型")
    @ApiResponses({
          @ApiResponse(code = 200, message = "模型修改成功"),
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/modifyModel", method = RequestMethod.POST)
    public RestResponse modifyModel(@Validated @RequestBody BoothModelDTO dto) {
        boothService.modifyModel(dto);
        return new RestResponse(CommonExceptionEnum.MODEL_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 27)
    @ApiOperation(value = "展位_图片")
    @ApiResponses({
          @ApiResponse(code = 200, message = "模型修改成功"),
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/modifyPicture", method = RequestMethod.POST)
    public RestResponse modifyPicture(@Validated @RequestBody BoothPictureDTO dto) {
        boothService.modifyPicture(dto);
        return new RestResponse(CommonExceptionEnum.PICTURE_MODIFIED_SUCCESSFULLY.getMsg());
    }

    @ApiOperationSupport(order = 28)
    @ApiOperation(value = "根据展位id和展位位置查询展位信息", response = BoothDTO.class)
    @ApiImplicitParams({
          @ApiImplicitParam(name = "showroomId", value = "展厅id", required = true, paramType = "query", dataType = "int"),
          @ApiImplicitParam(name = "boothOrder", value = "展位位置", required = true, paramType = "query", dataType = "int")
    })
    @ApiResponses({
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/selectBoothByShowroomIdAndBoothOrder", method = RequestMethod.GET)
    public RestResponse selectBoothByShowroomIdAndBoothOrder(@NotNull(message = "展厅id不能为空") @Range(min = 1, message = "展厅id值最小为1") Integer showroomId,
                                                             @Range(min = 1, max = CommonConst.NUMBER_OF_BOOTHS, message = "展位在展厅中的位置值不符合规范(1-" + CommonConst.NUMBER_OF_BOOTHS + ")")
                                                             @NotNull(message = "展位在展厅中的位置不能为空") Integer boothOrder) {
        BoothDTO result = boothService.selectBoothByShowroomIdAndBoothOrder(showroomId, boothOrder);
        return new RestResponse().put(result);
    }

    @ApiOperationSupport(order = 29)
    @ApiOperation(value = "根据展厅id查询,展厅内展位信息_前台,无需登录", response = BoothFrontDTO.class)
    @ApiImplicitParam(name = "showroomId", value = "展厅id", required = true, paramType = "query", dataType = "int")
    @ApiResponse(code = 21005, message = "展厅不存在")
    @RequestMapping(value = "/selectShowroomAllBoothByShowroomId", method = RequestMethod.GET)
    public RestResponse selectShowroomAllBoothByShowroomId(@NotNull(message = "展厅id不能为空") @Range(min = 1, message = "展厅id值最小为1") Integer showroomId, HttpServletRequest request) {
        List<BoothFrontDTO> result = boothService.selectShowroomAllBoothByShowroomId(showroomId, request);
        return new RestResponse().put(result);
    }

    @ApiOperationSupport(order = 30)
    @ApiOperation(value = "回显展位上是否有信息(返回结果:展位上有信息存在的展位位置集合)_前台")
    @ApiImplicitParam(name = "showroomId", value = "展厅id", required = true, paramType = "query", dataType = "int")
    @ApiResponses({
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/echoWhetherThereIsInformationOnTheBoothFront", method = RequestMethod.GET)
    public RestResponse echoWhetherThereIsInformationOnTheBoothFront(@NotNull(message = "展厅id不能为空") @Range(min = 1, message = "展厅id值最小为1") Integer showroomId) {
        List<Integer> result = boothService.echoWhetherThereIsInformationOnTheBoothFront(showroomId);
        return new RestResponse().put(result);
    }

    @ApiOperationSupport(order = 31)
    @ApiOperation(value = "根据展位id和展位位置查询展位信息_前台", response = BoothDTO.class)
    @ApiImplicitParams({
          @ApiImplicitParam(name = "showroomId", value = "展厅id", required = true, paramType = "query", dataType = "int"),
          @ApiImplicitParam(name = "boothOrder", value = "展位位置", required = true, paramType = "query", dataType = "int")
    })
    @ApiResponses({
          @ApiResponse(code = 21005, message = "展厅不存在"),
    })
    @RequestMapping(value = "/selectBoothByShowroomIdAndBoothOrderFront", method = RequestMethod.GET)
    public RestResponse selectBoothByShowroomIdAndBoothOrderFront(@NotNull(message = "展厅id不能为空") @Range(min = 1, message = "展厅id值最小为1") Integer showroomId,
                                                                  @Range(min = 1, max = CommonConst.NUMBER_OF_BOOTHS, message = "展位在展厅中的位置值不符合规范(1-" + CommonConst.NUMBER_OF_BOOTHS + ")")
                                                                  @NotNull(message = "展位在展厅中的位置不能为空") Integer boothOrder, HttpServletRequest request) {
        BoothDTO result = boothService.selectBoothByShowroomIdAndBoothOrderFront(showroomId, boothOrder, request);
        return new RestResponse().put(result);
    }

    // 处理描述的语言mp3(手动上传,讯飞生成如何判断,查询时判断音频是否为空,不为 空直接返回,为空再判断是否有描述,有描述文字就调用讯飞生成音频,并保存)
    // 不同类型展厅,展位的类型(2d/3d)
    // excel导入功能

}
